package com.kobe.tools.hystrix;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：caopengfei
 * @date ：2020/12/4
 */
@RestController
@RequestMapping("test")

public class TestController {


    @GetMapping("hystrix/start")
    public String hystrixStart() throws Exception{
        for(int i = 0 ; i< 100 ;i++){
            final int index = i;
            Thread.sleep(500);
            new Thread() {
                @Override
                public void run() {
                    long start = System.currentTimeMillis();
                    HttpClientHystrixCommand command = new HttpClientHystrixCommand(null,"123123asdasd",6000);
                    String result = command.execute();
                    System.out.println("线程"+index+"  执行时间："+(System.currentTimeMillis()-start)+" 执行结果: "+result);
                };
            }.start();

        }
        return "ok";
    }
}
